﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace DutyWeb.UserControls
{
    public partial class TabPages : System.Web.UI.UserControl
    {
        public event EventHandler TabsClick;//声明一个不含任何事件参数的委托方法
        public int SelectIndex
        {
            get
            {
                return DataList1.SelectedIndex;
            }
        }
        protected void Page_Load()
        {
            if (!Page.IsPostBack)
            {
                List<string> tabs = new List<string>();
                tabs.Add("新增");
                tabs.Add("查看");
                DataList1.DataSource = tabs;
                DataList1.DataBind();
                DataList1.SelectedIndex = 0;
            }

        }
        protected void SelectedIndexChanged(object sender, System.EventArgs e)
        {
            //判断委托存在
            if (TabsClick != null)
            {
                //前一个参数是触发事件的对象（用户控件本身，这里的this不是DataList），后一个参数表明该事件数据为空
                TabsClick(this, EventArgs.Empty); //实现委托方法
            }
        }


    }
}